home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / coding / 80x86 / incd2asm.lzh / CODE.LIB < prev    next >
Text File  |  1992-05-28  |  7KB  |  260 lines

  1. SetBlock        proc
  2.                 mov     ah,4ah
  3.         int    21h
  4.                 jc      SetBlockError
  5.                 ret
  6. SetBlockError:
  7.                 push    ax
  8.                 mov     ax,0003h
  9.                 int     10h
  10.                 pop     ax
  11.  
  12.                 cmp     ax,7
  13.                 jz      Set10
  14.         cmp    ax,8
  15.                 jz      Set20
  16.                 cmp     ax,9
  17.                 jz      Set30
  18.                 lea     dx,SetUnknown
  19.                 jmp     short SetBlockPrint
  20. Set10:          lea     dx,SetError7
  21.                 jmp     short SetBlockPrint
  22. Set20:          lea     dx,SetError8
  23.                 jmp     short SetBlockPrint
  24. Set30:          lea     dx,SetError9
  25.  
  26. SetBlockPrint:  mov     ah,9
  27.              int    21h
  28.                 mov     ax,4c00h
  29.                 int     21h
  30.                 endp
  31.  
  32. Allocate        proc
  33.                 mov     ah,48h
  34.         int    21h
  35.                 jc      AllocateError
  36.                 ret
  37. AllocateError:
  38.                 push    ax
  39.                 mov     ax,0003h
  40.                 int     10h
  41.                 pop     ax
  42.  
  43.                 cmp     ax,7
  44.                 jz      Allo10
  45.         cmp    ax,8
  46.                 jz      Allo20
  47.                 lea     dx,SetUnknown
  48.                 jmp     short AllocatePrint
  49. Allo10:         lea     dx,SetError7
  50.                 jmp     short AllocatePrint
  51. Allo20:         lea     dx,SetError8
  52.  
  53. AllocatePrint:  mov     ah,9
  54.              int    21h
  55.                 mov     ax,4c00h
  56.                 int     21h
  57.                 endp
  58.  
  59. DeAllocate      proc
  60.                 mov     ah,49h
  61.         int    21h
  62.                 jc      DeAlloError
  63.                 ret
  64. DeAlloError:
  65.                 push    ax
  66.                 mov     ax,0003h
  67.                 int     10h
  68.                 pop     ax
  69.  
  70.                 cmp     ax,7
  71.                 jz      DeA10
  72.                 cmp     ax,9
  73.                 jz      DeA20
  74.                 lea     dx,SetUnknown
  75.                 jmp     short DeAlloPrint
  76. DeA10:          lea     dx,SetError7
  77.                 jmp     short DeAlloPrint
  78. DeA20:          lea     dx,SetError9
  79.  
  80. DeAlloPrint:    mov     ah,9
  81.              int    21h
  82.                 mov     ax,4c00h
  83.                 int     21h
  84.                 endp
  85.  
  86.  
  87. Depack:         PUSH    AX
  88.                 MOV     AX,BP
  89.                 AND     AX,7
  90.                 SHR     BP,1
  91.                 SHR     BP,1
  92.                 SHR     BP,1
  93.                 CMP     AX,0
  94.                 JE      ax_0
  95.                 MOV     AX,1
  96. ax_0:           ADD     BP,AX
  97.                 SHR     BX,1
  98.                 SHR     BX,1
  99.                 SHR     BX,1
  100.                 POP     AX
  101.                 push    cx
  102.                 mov     cl,al
  103.                 mov     al,1
  104.                 shl     al,cl
  105.                 MOV     AH,AL
  106.                 NOT     AH
  107.                 pop     cx
  108. Depackl1:       PUSH    CX
  109.                 PUSH    AX
  110.                 MOV     CX,DX
  111. Planes:         PUSH    CX
  112.                 PUSH    DI
  113.                 PUSH    BP
  114. NotherOne:      XOR     CX,CX
  115.                 MOV     CL,DS:[SI]
  116.                 INC     SI
  117.                 CMP     CL,127
  118.                 JA      CrunchyNut
  119.                 INC     CX
  120.                 SUB     BP,CX
  121.                 push    bx
  122. PutByte:        mov     bl,ds:[si]
  123.                 inc     si
  124.                 push    cx
  125.                 mov     cx,8
  126. orpixel:        rcl     bl,1
  127.                 jc      carry_set
  128.                 and     es:[di],ah
  129.                 jmp     set_done
  130. carry_set:      or      es:[di],al
  131. set_done:       inc     di
  132.                 loop    orpixel
  133.                 pop     cx
  134.                 LOOP    PutByte
  135.                 pop     bx
  136.                 JMP     LineOk
  137. CrunchyNut:     SUB     CX,257
  138.                 NEG     CX
  139.                 SUB     BP,CX
  140.                 push    bx
  141.                 mov     bl,ds:[si]
  142.                 mov     bh,bl
  143.                 inc     si
  144. PutByte2:       push    cx
  145.                 mov     cx,8
  146. orpixel2:       rcl     bl,1
  147.                 jc      carry_set2
  148.                 and     es:[di],ah
  149.                 jmp     set_done2
  150. carry_set2:     or      es:[di],al
  151. set_done2:      inc     di
  152.                 loop    orpixel2
  153.                 mov     bl,bh
  154.                 pop     cx
  155.                 LOOP    PutByte2
  156.                 pop     bx
  157. LineOk:         CMP     BP,0
  158.                 JNE     NotherOne
  159.                 POP     BP
  160.                 POP     DI
  161.                 POP     CX
  162.                 SHL     AL,1
  163.                 STC
  164.                 RCL     AH,1
  165.                 LOOP    Planes
  166.                 push    bp
  167.                 push    bx
  168.                 shl     bp,1
  169.                 shl     bp,1
  170.                 shl     bp,1
  171.                 shl     bx,1
  172.                 shl     bx,1
  173.                 shl     bx,1
  174.                 ADD     DI,BP
  175.                 ADD     DI,BX
  176.                 pop     bx
  177.                 pop     bp
  178.                 POP     AX
  179.                 POP     CX
  180.                 LOOP    XDepackl1
  181.                 RET
  182.  
  183. XDepackl1:      jmp     Depackl1
  184.  
  185. waitraster:     mov     dx,3dah
  186. ras1:           in      al,dx
  187.                 test    al,8
  188.                 jnz     ras1
  189. ras2:           cli
  190.                 in      al,dx
  191.                 test    al,8
  192.                 jz      ras2
  193.                 sti
  194.                 ret
  195.  
  196. Toogle:         mov     dx,3c4h
  197.                 mov     al,1
  198.                 out     dx,al
  199.                 inc     dx
  200.                 in      al,dx
  201.                 xor     al,00100000b
  202.                 out     dx,al
  203.                 ret
  204.  
  205.  
  206. _ES16            dw      0
  207. _BX16            dw      0
  208. _ES9             dw      0
  209. _BX9             dw      0
  210.  
  211. SetNewVectors:
  212.                 push    cs
  213.                 pop     ds
  214.  
  215.                 mov     ax,3516h           ;Get int vector
  216.                 int     21h
  217.                 mov     _ES16,es
  218.                 mov     _BX16,bx
  219.  
  220.                 mov     ax,3509h           ;Get int vector
  221.                 int     21h
  222.                 mov     _ES9,es
  223.                 mov     _BX9,bx
  224.  
  225.                 mov     ax,2516h           ;Set int vector
  226.                 lea     dx,NewInt16
  227.                 int     21h
  228.  
  229.                 mov     ax,2509h           ;Set int vector
  230.                 lea     dx,NewInt9
  231.                 int     21h
  232.                 ret
  233.  
  234. RestoreVectors: push    cs
  235.                 pop     ds
  236.  
  237.                 mov     ax,2516h
  238.                 mov     dx,_BX16
  239.                 mov     ds,_ES16
  240.                 int     21h
  241.  
  242.                 push    cs
  243.                 pop     ds
  244.  
  245.                 mov     ax,2509h
  246.                 mov     dx,_BX9
  247.                 mov     ds,_ES9
  248.                 int     21h
  249.                 ret
  250.  
  251. NewInt9:        push    ax
  252.                 mov     al,20h
  253.                 out     20h,al
  254.                 pop     ax
  255. NewInt16:       iret
  256.  
  257.  
  258.  
  259.  
  260.